home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / vol16n12.zip / IPC.ZIP / CATCH.ZIP / CATCHDLG.CPP < prev    next >
C/C++ Source or Header  |  1997-02-12  |  2KB  |  104 lines

  1. // CatchDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Catch.h"
  6. #include "CatchDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CCatchDlg dialog
  16.  
  17. CCatchDlg::CCatchDlg(CWnd* pParent /*=NULL*/)
  18.     : CDialog(CCatchDlg::IDD, pParent)
  19. {
  20.     //{{AFX_DATA_INIT(CCatchDlg)
  21.         // NOTE: the ClassWizard will add member initialization here
  22.     //}}AFX_DATA_INIT
  23.     m_hIcon = AfxGetApp()->LoadStandardIcon(IDI_WINLOGO);
  24. }
  25.  
  26. void CCatchDlg::DoDataExchange(CDataExchange* pDX)
  27. {
  28.     CDialog::DoDataExchange(pDX);
  29.     //{{AFX_DATA_MAP(CCatchDlg)
  30.     DDX_Control(pDX, IDC_LISTBOX, m_wndListBox);
  31.     //}}AFX_DATA_MAP
  32. }
  33.  
  34. BEGIN_MESSAGE_MAP(CCatchDlg, CDialog)
  35.     //{{AFX_MSG_MAP(CCatchDlg)
  36.     ON_WM_PAINT()
  37.     ON_WM_QUERYDRAGICON()
  38.     ON_BN_CLICKED(IDC_CLEAR_ALL, OnClearAll)
  39.     //}}AFX_MSG_MAP
  40.     ON_MESSAGE (WM_COPYDATA, OnCopyData)
  41. END_MESSAGE_MAP()
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CCatchDlg message handlers
  45.  
  46. BOOL CCatchDlg::OnInitDialog()
  47. {
  48.     CDialog::OnInitDialog();
  49.  
  50.     SetIcon(m_hIcon, TRUE);            // Set big icon
  51.     SetIcon(m_hIcon, FALSE);        // Set small icon
  52.     
  53.     return TRUE;
  54. }
  55.  
  56. void CCatchDlg::OnPaint() 
  57. {
  58.     if (IsIconic())
  59.     {
  60.         CPaintDC dc(this);
  61.  
  62.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  63.  
  64.         // Center icon in client rectangle
  65.         int cxIcon = GetSystemMetrics(SM_CXICON);
  66.         int cyIcon = GetSystemMetrics(SM_CYICON);
  67.         CRect rect;
  68.         GetClientRect(&rect);
  69.         int x = (rect.Width() - cxIcon + 1) / 2;
  70.         int y = (rect.Height() - cyIcon + 1) / 2;
  71.  
  72.         // Draw the icon
  73.         dc.DrawIcon(x, y, m_hIcon);
  74.     }
  75.     else
  76.     {
  77.         CDialog::OnPaint();
  78.     }
  79. }
  80.  
  81. HCURSOR CCatchDlg::OnQueryDragIcon()
  82. {
  83.     return (HCURSOR) m_hIcon;
  84. }
  85.  
  86. LONG CCatchDlg::OnCopyData (UINT wParam, LONG lParam)
  87. {
  88.     PCOPYDATASTRUCT pcds = (PCOPYDATASTRUCT) lParam;
  89.  
  90.     TCHAR* pString = new TCHAR[pcds->dwData];
  91.     ::CopyMemory (pString, pcds->lpData, pcds->cbData);
  92.     pString[pcds->dwData - 1] = 0;    // Just to be sure
  93.  
  94.     m_wndListBox.InsertString (0, (LPCTSTR) pString);
  95.  
  96.     delete[] pString;
  97.     return 1;
  98. }
  99.  
  100. void CCatchDlg::OnClearAll() 
  101. {
  102.     m_wndListBox.ResetContent ();
  103. }
  104.